import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/from';

import 'rxjs/add/operator/map';
import 'rxjs/add/operator/reduce';


let persons = [
    { name: 'David', age: 3, salary: 2000 },
    { name: 'Dav', age: 17, salary: 12000 },
    { name: 'Lomo', age: 20, salary: 16000 },
    { name: 'Dev', age: 20, salary: 10000 },
    { name: 'Amy', age: 7, salary: 34000 },
];


Observable.from(persons).map(p => p.salary).reduce((total, current) => total + current, 1).subscribe(
    total => {
        console.log(`total salary is: ${total}`)
        // console.log(persons);
    },
    err => console.log(err),
    () => console.log('finished.')
);
